const express = require('express')
const cors = require("cors")
const app = new express()

const path = require('path')

app.use(cors())
app.use(express.json())

// app.use(express.static(path.join(__dirname, 'dist_local')))
app.use(express.static(path.join(__dirname, 'dist')))



const sysRouter = require('./router/sys')
const userRouter = require('./router/sys/user')
const permRouter = require('./router/sys/permission')
const roleRouter = require('./router/sys/role')
const cityRouter = require('./router/sys/city')

const hometRouter = require('./router/home')
const deptRouter = require('./router/company/department')

const socialRouter = require('./router/social_securitys')
const salaryRouter = require('./router/salarys')
const approvalRouter = require('./router/user/process')
const atteRouter = require('./router/attendances')

app.use('/sys', sysRouter)
app.use('/sys/user', userRouter)
app.use('/sys/permission', permRouter)
app.use('/sys/role', roleRouter)
app.use('/sys/city', cityRouter)

app.use('/home', hometRouter)
app.use('/company/department', deptRouter)

app.use('/social_securitys', socialRouter)
app.use('/salarys', salaryRouter)
app.use('/user/process', approvalRouter)
app.use('/attendances', atteRouter)

// 全局错误捕捉器
app.use((err, req, res, next) => {
  console.error('未处理的错误:', err)
  res.status(500).send('服务器错误')
})
app.listen(1104, () => {
  console.log('1104running...')
})